package com.chen.utils;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

//@Configuration
public class JedisConnectionFactory {

    private static final JedisPool jedisPool;

    static {
        //配置连接池
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxTotal(10); //设置最大连接数
        poolConfig.setMaxIdle(8);   //设置最大空闲连接数
        poolConfig.setMinIdle(2);  //设置最小空闲连接数
        poolConfig.setMaxWaitMillis(10000); //设置最大等待时间
        //创建连接池对象
        jedisPool = new JedisPool(poolConfig, "192.168.30.130", 6379,10000);
    }
    public static Jedis getJedis(){
        return jedisPool.getResource();
    }
}
